//
//  SpecialStarDetailFooterCell.swift
//  甜言蜜语
//
//  Created by yingli_yanfa_liuxingyu on 16/8/17.
//  Copyright © 2016年 wl. All rights reserved.
//

import UIKit

class SpecialStarDetailFooterCell: UITableViewCell, UITableViewDelegate, UITableViewDataSource
    
{
    
    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var allBtn: UIButton!
    @IBOutlet weak var recruitBtn: UIButton!
    var modelList: specialStarDetailInfo?{
        didSet{
            self.tableView.reloadData()
        }
    }
    var cellHeight = 0
    override func awakeFromNib() {
        super.awakeFromNib()
        self.tableView.delegate = self
        self.tableView.dataSource = self
         publicMethod.hiddleExtendCellForTableView(self.tableView)
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    func setCellContentWithCellInfo(cellInfo: specialStarDetailInfo?) -> Void {
        self.modelList = cellInfo
        if self.modelList?.infomations?.count == 0{
            cellHeight = 0
        }else{
            for index in 0...(self.modelList?.infomations?.count)! - 1 {
                
                let newsModel = self.modelList?.infomations![index]
                
                cellHeight += Int(newsModel!.cellType!.cellHeight())
            }

        }
        
        
    }
    
    //MARK:tableviewDataSource
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        if self.modelList?.infomations?.count == 0 || self.modelList?.infomations?.count == nil{
            return 0
        }else{
            return (self.modelList?.infomations?.count)!
        }
        
    }
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        
        let newsModel = self.modelList?.infomations![indexPath.row]
        return newsModel!.cellType!.cellHeight()
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        let model = self.modelList?.infomations![indexPath.row]
        
        let cell = tableView.dequeueReusableCellWithIdentifier(model!.cellType.rawValue, forIndexPath: indexPath) as! NewsCell
        
        cell.newsModel = model
        
        return cell

    }
    // MARK: - Table view delegate
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        
        tableView.deselectRowAtIndexPath(indexPath, animated: true)
        
    }
     //MARK:target
    func showInfo(){
        
    }
    
}
